
package com.bluelinelabs.conductor.demo.controllers;

import ohos.aafwk.content.IntentParams;
import ohos.agp.components.Text;

import com.bluelinelabs.conductor.conductor.utile.TextUtils;
import com.bluelinelabs.conductor.demo.ResourceTable;
import com.bluelinelabs.conductor.demo.controllers.base.BaseController;

/**
 * lipeiquan
 *
 * @since 2021-05-06
 */
public class TextController extends BaseController {
    public static final String KEY_TEXT = "TextController.text";

    public static final String KEY_NEXT_RETAIN = "next_retain.text";
    public static final String KEY_NEXT_RELEASE = "next_release.text";
    private int mFlag = 1;

    public TextController(IntentParams args) {
        super(ResourceTable.Layout_controller_text, args);
    }

    public TextController(IntentParams args, int flag) {
        super(ResourceTable.Layout_controller_text, args);
        mFlag = flag;
    }

    @Override
    public void onViewCreated(ohos.agp.components.Component component) {
        Text Id_text_view = (Text) component.findComponentById(ResourceTable.Id_text_view);
        String key_next_retain = null;
        String key_next_release = null;
        if (mFlag == 1) {
            key_next_retain = (String) getArgs().getParam(KEY_NEXT_RETAIN);
        } else {
            key_next_release = (String) getArgs().getParam(KEY_NEXT_RELEASE);
        }
        String key_text = (String) getArgs().getParam(KEY_TEXT);
        String word;
        if (!TextUtils.isEmpty(key_next_retain)) {
            word = key_next_retain;
        } else if (!TextUtils.isEmpty(key_next_release)) {
            word = key_next_release;
        } else {
            word = key_text;
        }
        Id_text_view.setText(word);
    }
}
